﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace AdminModule.CustomXAMLElements
{
    public sealed partial class TemplateSelector : ContentControl
    {
        private List<IMDataTemplate> templates = new List<IMDataTemplate>();
        public List<IMDataTemplate> Templates
        {
            get
            {
                return this.templates;
            }
            set
            {
                this.templates = value;
            }
        }

        protected override void OnContentChanged(object oldContent, object newContent)
        {
            base.OnContentChanged(oldContent, newContent);
            foreach (IMDataTemplate t in this.templates)
            {
                string s = newContent.GetType().Name;
                if (t.IMName == s)
                {
                    ContentTemplate = t;
                }
            }
        }
    }

    public sealed class IMDataTemplate : DataTemplate
    {
        private string imname;
        public string IMName
        {
            get
            {
                return this.imname;
            }
            set
            {
                this.imname = value;
            }
        }
    }
}
